<?php
class Client_model extends Model
{
    function create_member()
    {

        $new_member_insert_data = array(
            //'carnet' => $this->input->post('carnet'),
            'nombre' => $this->input->post('nombre'),
            'apellido1' => $this->input->post('apellido1'),
            'apellido2' => $this->input->post('apellido2'),
            'direccion'=> $this->input->post('direccion'),
            'telefono' => $this->input->post('telefono'),
            'email' => $this->input->post('email'),
            'pais' => $this->input->post('pais'),
             'local' => $this->input->post('local')
            //'password' => md5($this->input->post('password'))
        );
        //   log_message('INFO',"*************".print_r($new_member_insert_data,true));
        $insert = $this->db->insert('cliente', $new_member_insert_data);
        return $insert;
    }
    // busqueda
    function obtener($id)
    {
        $cliente = array();

        $query = $this->db->get_where('cliente', array('carnet' => $id));
        $cliente = $query->result();
        return $cliente;

    }

    function eliminar()
    {
        $carnet = $this->input->post('carnet');
        $this->db->where('carnet', $carnet);
        return $this->db->delete('cliente');
    }

    function modificar()
    {
        $new_member_update_data = array(
            'carnet' => $this->input->post('carnet'),
            'nombre' => $this->input->post('nombre'),
            'apellido1' => $this->input->post('apellido1'),
            'apellido2' => $this->input->post('apellido2'),
            'direccion'=> $this->input->post('direccion'),
            'telefono' => $this->input->post('telefono'),
            'email' => $this->input->post('email'),
            'ciudad' => $this->input->post('ciudad')
            //'password' => md5($this->input->post('password'))
        );
        //   log_message('INFO',"*************".print_r($new_member_insert_data,true));
        $this->db->where('carnet', $new_member_update_data['carnet']);
        return $this->db->update('cliente', $new_member_update_data);


    }

    function listar_datos_cliente()
    {
        $query = $this->db->get('cliente');
        return $query->result();
    }
}